#ifndef EXPORTEXCELOBJECT_H
#define EXPORTEXCELOBJECT_H

#include <QObject>
#include <QTableView>
#include <QList>
#include <QSqlDatabase>
#include <QString>
#include <QVariant>

class ExportColumn
{
public:

    ExportColumn(int col,QString name,QString type)
        :column(col),columnName(name),columnType(type)
    { }

    ~ExportColumn(){}


    int column;
    QString columnName;
    QString columnType;
};

class ExportExcelObject : public QObject
{
    Q_OBJECT
public:
    explicit ExportExcelObject(QObject *parent = 0);
    ExportExcelObject(const QString &filepath, const QString &sheetTitle,
                          QTableView *tableview):exportFilePath(filepath),
                          sheetName(sheetTitle), tableView(tableview){};
    ~ExportExcelObject(){QSqlDatabase::removeDatabase(this->connectionName);removeAllColumns();}
    inline void setExportFilePath(const QString path);
    inline void setExcelSheetName(const QString name);
    inline void setConnectionName(QString connectionName);
    inline void setTableView(QTableView *view);
    void addColumn(int column,const QString &columnName,const QString &columnType);
    //inline void removeColumn(int column);
    inline int  removeAllColumns();
    int export2Excel();

signals:

public slots:
private:
    QString exportFilePath;
    QString sheetName;
    QString connectionName;
    QTableView *tableView;
    QList<ExportColumn*> columnList;

};

#endif // EXPORTEXCELOBJECT_H
